package com.linsen.core.lock.constant;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 全局常量枚举
 *
 * @author zhaoyong
 * @date 2023/3/21
 */
@Getter
@AllArgsConstructor
public enum GlobalConstant {

    REDIS_CONNECTION_PREFIX("redis://", "Redis地址配置前缀"),
    ;

    @JsonValue
    private final String constant_value;
    private final String constant_desc;

    private static final Map<String, GlobalConstant> VALUES = new HashMap<>();

    static {
        for (final GlobalConstant globalConstant : GlobalConstant.values()) {
            GlobalConstant.VALUES.put(globalConstant.getConstant_value(), globalConstant);
        }
    }

    @JsonCreator
    public static GlobalConstant getByValue(String value) {
        return GlobalConstant.VALUES.get(value);
    }
}
